﻿using System;
using System.Data;
using System.Data.Common;
using System.Text;
using Besture.Common;
using Besture.Model;

namespace Besture.Dal
{
    public partial class RoomCategoryDal : BaseDataAccess
    {
        /// <summary>
        /// 根据类型获取房型类别数据
        /// </summary>
        /// <param name="categoryType"></param>
        /// <returns></returns>
        public DataTable GetDataTableByCategoryType(int categoryType)
        {
            try
            {
                StringBuilder selectSql = new StringBuilder();
                selectSql.Append(string.Format(@"
                SELECT tc.*,dt.Name FROM TBRoomCategory tc
                INNER JOIN dbo.TBDictionaryType dt ON dt.Code=tc.CategoryType AND dt.IsDeleted=0 AND tc.IsDeleted=0
                WHERE tc.CategoryType={0} AND dt.Type={1}
                ORDER BY tc.SortID DESC ", categoryType, Constants.DICTIONARY_TYPE_HOTEL_ROOM_CATEGORY));
                DbCommand ldcDBCommand = base.GetCommand(selectSql.ToString());
                DataTable dt = base.GetDataSet(ldcDBCommand).Tables[0];
                return dt;
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
    }
}

